package com.example.understand_compose1.testcase_activity

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.ui.geometry.RoundRect
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.fragment.app.FragmentActivity
import coil.Coil
import coil.load
import coil.transform.CircleCropTransformation
import coil.transform.RoundedCornersTransformation
import com.example.understand_compose1.R
import com.example.understand_compose1.databinding.ActivityFetCoilLoadImgBinding
import com.example.understand_compose1.testcase_data.const_net_resource.caseImg

class FetCoilLoadImgActivity : FragmentActivity() {
    lateinit var binding: ActivityFetCoilLoadImgBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityFetCoilLoadImgBinding.inflate(layoutInflater)

        enableEdgeToEdge()
        setContentView(binding.root)

        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }

        binding.ivCoil1
            .load(caseImg){
                transformations(CircleCropTransformation())

            }

        binding.ivCoil2
            .load(R.drawable.ic_send){
                placeholder(R.mipmap.qq_icon)
                crossfade(true)
                // 2s淡入淡出
                crossfade(2000)
            }

        binding.ivCoil3
            .load(caseImg){
                transformations(RoundedCornersTransformation(100f))
            }

    }
}